using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Windows.Forms;
using ZedGraph;

namespace ICP_MS.Plugin.HPLC;

public class FormCurves : Form
{
	private ExperimentDatas experiment = null;

	private ExperimentDB db = null;

	private HPLCIntegerRegions currentregion = null;

	private List<HPLCStatisticResults> results = new List<HPLCStatisticResults>();

	private int currentMethod = 0;

	private IsotopeInfos selectIsotope;

	private HPLCIntegerRegions selectregion;

	private bool isotopeChanged = true;

	private IContainer components = null;

	private SplitContainer splitContainer2;

	private GroupBox gbOption;

	private ComboBox cbForce;

	private ComboBox cbWeight;

	private System.Windows.Forms.Label lblForce;

	private System.Windows.Forms.Label lblWeight;

	private GroupBox gbCalibration;

	private ComboBox cbTypes;

	private TableLayoutPanel tableLayoutPanel3;

	private GroupBox groupBox7;

	private Button btnRefresh;

	private GroupBox groupBox8;

	private DataGridView dgvCalibrations;

	private ZedGraphControl graph;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn1;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn2;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn3;

	private DataGridViewTextBoxColumn dataGridViewTextBoxColumn4;

	private Panel panel1;

	private TextBox txtCoef;

	private TextBox txtCon;

	private TextBox txtCPS;

	private System.Windows.Forms.Label lblCoef;

	private System.Windows.Forms.Label lblCon;

	private System.Windows.Forms.Label lblCPS;

	private DataGridViewTextBoxColumn colSample;

	private DataGridViewTextBoxColumn colConcentration;

	private DataGridViewTextBoxColumn colTestValue;

	private DataGridViewTextBoxColumn colCPS;

	private DataGridViewCheckBoxColumn colInclude;

	private TreeView treeIsotope;

	public FormCurves()
	{
		InitializeComponent();
	}

	public void SetParams(ExperimentDatas experiment, ExperimentDB db)
	{
		this.experiment = experiment;
		this.db = db;
	}

	public void UpdateSelectedIsotopes(object sender, EventArgs e)
	{
		isotopeChanged = true;
	}

	public void UpdateSelectedRegion(object sender, EventArgs e)
	{
		isotopeChanged = true;
	}

	public void UpdateInternalStandards(object sender, EventArgs e)
	{
		isotopeChanged = true;
	}

	public void UpdateSamples(object sender, EventArgs e)
	{
	}

	private void FormCurves_Load(object sender, EventArgs e)
	{
		base.WindowState = FormWindowState.Maximized;
		graph.GraphPane.Title.Text = "";
		graph.GraphPane.XAxis.Title.Text = Lang.Txt("FormCurve.Curve.Y.Title.Text");
		graph.GraphPane.YAxis.Title.Text = Lang.Txt("FormCurve.Curve.X.Title.Text2");
		experiment.regionChanged += experiment_regionChanged;
		cbForce.SelectedIndex = 0;
		cbWeight.SelectedIndex = 0;
		SelectDefaulMethod();
		SetupIsotopeList();
		ApplyResources();
	}

	private void experiment_regionChanged(object sender, EventArgs e)
	{
		SetupIsotopeList();
	}

	private void ApplyResources()
	{
		Text = Lang.Txt("FormCurve.Title.Text");
		gbCalibration.Text = Lang.Txt("FormCurve.Type.Text");
		gbOption.Text = Lang.Txt("FormCurve.Option.Text");
		groupBox7.Text = Lang.Txt("FormCurve.CurveParam.Text");
		groupBox8.Text = Lang.Txt("FormCurve.StandardSample.Text");
		lblCoef.Text = Lang.Txt("FormCurve.RR.Text");
		lblForce.Text = Lang.Txt("FormCurve.Force.Text");
		lblWeight.Text = Lang.Txt("FormCurve.WeightMode.Text");
		colConcentration.HeaderText = Lang.Txt("FormCurve.Columns.STDConcentration.Text");
		colCPS.HeaderText = Lang.Txt("FormCurve.Columns.CPS.Text");
		colInclude.HeaderText = Lang.Txt("FormCurve.Columns.Include.Text");
		colSample.HeaderText = Lang.Txt("FormCurve.Columns.SampleName.Text");
		colTestValue.HeaderText = Lang.Txt("FormCurve.Columns.MConcentration.Text");
		btnRefresh.Text = Lang.Txt("FormCurve.Recalculation.Text");
		cbTypes.Items[0] = Lang.Txt("AddFormCurves.None");
		cbTypes.Items[1] = Lang.Txt("AddFormCurves.FullyQuantitative");
		cbTypes.Items[2] = Lang.Txt("AddFormCurves.AddStandard");
		cbTypes.Items[3] = Lang.Txt("AddFormCurves.SemiQuantitative");
		cbWeight.Items[0] = Lang.Txt("AddFormCurves.None");
		cbWeight.Items[1] = Lang.Txt("AddFormCurves.AbsoluteError");
		cbWeight.Items[2] = Lang.Txt("AddFormCurves.RelativeError");
		cbForce.Items[0] = Lang.Txt("AddFormCurves.None");
		cbForce.Items[1] = Lang.Txt("AddFormCurves.Blank");
		cbForce.Items[2] = Lang.Txt("AddFormCurves.Origin");
		lblCPS.Text = Lang.Txt("FormScanLA.IntensityIntercept");
		lblCon.Text = Lang.Txt("FormScanLA.COnCIntercept");
	}

	private void SelectDefaulMethod()
	{
		foreach (IsotopeInfos isotope in experiment.Isotopes)
		{
			if (isotope.method == 1 || isotope.method == 2)
			{
				currentMethod = isotope.method;
				cbTypes.SelectedIndex = currentMethod;
				break;
			}
		}
	}

	public void SetupIsotopeList()
	{
		treeIsotope.Nodes.Clear();
		foreach (IsotopeInfos isotope in experiment.Isotopes)
		{
			if (isotope.method != currentMethod)
			{
				continue;
			}
			TreeNode node = treeIsotope.Nodes.Add(isotope.symbol);
			node.Tag = isotope;
			IEnumerable<HPLCIntegerRegions> regions = experiment.IntegerRegions.Where((HPLCIntegerRegions Regions) => Regions.symbol == isotope.symbol);
			List<string> regionid = new List<string>();
			foreach (HPLCIntegerRegions region in regions)
			{
				if (!regionid.Exists((string id) => id == region.ReferenceId))
				{
					TreeNode subnode = node.Nodes.Add(region.Label);
					subnode.Tag = region;
					regionid.Add(region.ReferenceId);
				}
			}
		}
	}

	private void ReLoadDatas()
	{
		SelectRegion();
		DrawCurves();
	}

	private void SelectRegion(HPLCIntegerRegions region = null)
	{
		if (region != null)
		{
			currentregion = region;
		}
		results.Clear();
		if (!experiment.Isotopes.Exists((IsotopeInfos isotope) => isotope.inter && isotope.symbol == region.symbol))
		{
			if (currentMethod == 1)
			{
				results.AddRange(from result in experiment.Statistics
					from sample in experiment.Samples
					where result.regionLabel == currentregion.ReferenceId && result.symbol == currentregion.symbol && result.stdCon >= 0.0 && result.sampleId == sample.guid && (sample.type == 0 || sample.type == 1) && sample.status == 1
					select result);
			}
			results.Sort((HPLCStatisticResults r0, HPLCStatisticResults r1) => r0.stdCon.CompareTo(r1.stdCon));
		}
		BindResults();
	}

	private void BindResults()
	{
		dgvCalibrations.AutoGenerateColumns = false;
		if (dgvCalibrations.DataSource == null)
		{
			dgvCalibrations.DataSource = results;
			return;
		}
		BindingContext[dgvCalibrations.DataSource].SuspendBinding();
		dgvCalibrations.DataSource = null;
		dgvCalibrations.DataSource = results;
		BindingContext[dgvCalibrations.DataSource].ResumeBinding();
	}

	private void DrawCurves()
	{
		graph.GraphPane.CurveList.Clear();
		graph.GraphPane.Title.Text = currentregion.Label;
		bool istdExist = experiment.Isotopes.Exists((IsotopeInfos isotope) => isotope.inter);
		if (istdExist)
		{
			graph.GraphPane.XAxis.Title.Text = Lang.Txt("HPLCForm.Text1");
			graph.GraphPane.YAxis.Title.Text = Lang.Txt("HPLCForm.Text2");
		}
		else
		{
			graph.GraphPane.XAxis.Title.Text = Lang.Txt("FormCurve.Curve.Y.Title.Text");
			graph.GraphPane.YAxis.Title.Text = Lang.Txt("FormCurve.Curve.X.Title.Text2");
		}
		IEnumerable<HPLCIsotopeCurve> curves = experiment.Curves.Where((HPLCIsotopeCurve curve) => curve.calculated && curve.symbol == currentregion.symbol && curve.regionLabel == currentregion.ReferenceId);
		if (curves != null && curves.Count() == 1)
		{
			txtCon.Text = curves.ElementAt(0).intercept2.ToString("F6");
			txtCPS.Text = curves.ElementAt(0).intercept1.ToString("F6");
			txtCoef.Text = curves.ElementAt(0).r.ToString("F6");
			double j = curves.ElementAt(0).k;
			double b = curves.ElementAt(0).b;
			IEnumerable<double> cps0 = from result in results
				where !result.include
				select result.avgCPS;
			IEnumerable<double> con0 = from result in results
				where !result.include
				select result.stdCon;
			if (istdExist)
			{
				con0 = from result in results
					where !result.include
					select result.stdCon / (100.0 - result.stdCon);
			}
			LineItem line0 = graph.GraphPane.AddCurve("", con0.ToArray(), cps0.ToArray(), Color.Red, SymbolType.Circle);
			line0.Line.IsVisible = false;
			line0.Symbol.Fill.Type = FillType.Solid;
			IEnumerable<double> cps1 = from result in results
				where result.include
				select result.avgCPS;
			IEnumerable<double> con1 = from result in results
				where result.include
				select result.stdCon;
			if (istdExist)
			{
				con1 = from result in results
					where result.include
					select result.stdCon / (100.0 - result.stdCon);
			}
			LineItem line1 = graph.GraphPane.AddCurve("", con1.ToArray(), cps1.ToArray(), Color.Blue, SymbolType.Circle);
			line1.Line.IsVisible = false;
			line1.Symbol.Fill.Type = FillType.Solid;
			double[] con2 = results.Select((HPLCStatisticResults result) => result.stdCon).ToArray();
			if (istdExist)
			{
				con2 = results.Select((HPLCStatisticResults result) => result.stdCon / (100.0 - result.stdCon)).ToArray();
			}
			double[] cps2 = new double[con2.Length];
			for (int i = 0; i < con2.Length; i++)
			{
				cps2[i] = con2[i] * j + b;
			}
			graph.GraphPane.AddCurve("", con2, cps2, Color.Black, SymbolType.None);
		}
		graph.GraphPane.AxisChange();
		graph.Refresh();
	}

	private void cbTypes_SelectedIndexChanged(object sender, EventArgs e)
	{
		switch (cbTypes.SelectedItem.ToString())
		{
		case "全定量":
			currentMethod = 1;
			break;
		case "标准加入":
			currentMethod = 2;
			break;
		case "半定量":
			currentMethod = 3;
			break;
		case "无":
			currentMethod = 0;
			break;
		}
		SetupIsotopeList();
	}

	private void btnRefreshResult_Click(object sender, EventArgs e)
	{
		btnRefresh.Enabled = false;
		FormWait wait = new FormWait();
		wait.StartPosition = FormStartPosition.CenterParent;
		wait.Text = Lang.Txt("FormCurve.Calculation.Calculate.Text");
		wait.Run += CalculateRun;
		wait.Complete += CalculateComplete;
		wait.Show();
	}

	private void CalculateRun(object sender, EventArgs e)
	{
		ProgressBar bar = sender as ProgressBar;
		if (bar != null)
		{
			Invoke((MethodInvoker)delegate
			{
				bar.Style = ProgressBarStyle.Marquee;
			});
		}
		experiment.RecalculatedAll();
	}

	private void CalculateComplete(object sender, EventArgs e)
	{
		Invoke((MethodInvoker)delegate
		{
			(sender as Form).Text = Lang.Txt("FormCurve.Calculation.Refresh.Text");
			if (isotopeChanged)
			{
				SetupIsotopeList();
				isotopeChanged = false;
			}
			ReLoadDatas();
			btnRefresh.Enabled = true;
		});
	}

	private void dgvCalibrations_CellFormatting(object sender, DataGridViewCellFormattingEventArgs e)
	{
		if (e.ColumnIndex == colConcentration.Index || e.ColumnIndex == colTestValue.Index || e.ColumnIndex == colCPS.Index)
		{
			e.Value = string.Format(new FormatValue(), "{0:U}", e.Value);
		}
	}

	private void FormCurves_Activated(object sender, EventArgs e)
	{
		SelectRegion();
	}

	private void dgvCalibrations_CellValueChanged(object sender, DataGridViewCellEventArgs e)
	{
		if (e.RowIndex >= 0 && e.ColumnIndex == colInclude.Index)
		{
			experiment.CalculateCurve(currentregion);
			DrawCurves();
		}
	}

	private void dgvCalibrations_CurrentCellDirtyStateChanged(object sender, EventArgs e)
	{
		if (dgvCalibrations.IsCurrentCellDirty)
		{
			dgvCalibrations.CommitEdit(DataGridViewDataErrorContexts.Commit);
		}
	}

	private void SetOptions()
	{
		foreach (IsotopeInfos isotope in experiment.Isotopes)
		{
			if (isotope.symbol == currentregion.symbol)
			{
				cbForce.SelectedIndex = isotope.force;
				cbWeight.SelectedIndex = isotope.weight;
				break;
			}
		}
	}

	private void cbForce_SelectedIndexChanged(object sender, EventArgs e)
	{
		if (currentMethod != 1 && currentMethod != 2)
		{
			return;
		}
		foreach (IsotopeInfos isotope in experiment.Isotopes)
		{
			if (isotope.symbol == currentregion.symbol)
			{
				int index = cbForce.SelectedIndex;
				isotope.force = index;
				break;
			}
		}
	}

	private void treeIsotope_AfterSelect(object sender, TreeViewEventArgs e)
	{
		if (e.Node.Equals(treeIsotope.Nodes[0]))
		{
			selectregion = null;
			selectIsotope = null;
		}
		else if (e.Node.Level == 0)
		{
			selectregion = null;
			selectIsotope = e.Node.Tag as IsotopeInfos;
		}
		else
		{
			selectIsotope = e.Node.Parent.Tag as IsotopeInfos;
			selectregion = e.Node.Tag as HPLCIntegerRegions;
		}
		if (selectregion != null)
		{
			SelectRegion(selectregion);
			SetOptions();
			DrawCurves();
		}
	}

	protected override void Dispose(bool disposing)
	{
		if (disposing && components != null)
		{
			components.Dispose();
		}
		base.Dispose(disposing);
	}

	private void InitializeComponent()
	{
		this.components = new System.ComponentModel.Container();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle1 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle2 = new System.Windows.Forms.DataGridViewCellStyle();
		System.Windows.Forms.DataGridViewCellStyle dataGridViewCellStyle3 = new System.Windows.Forms.DataGridViewCellStyle();
		this.splitContainer2 = new System.Windows.Forms.SplitContainer();
		this.treeIsotope = new System.Windows.Forms.TreeView();
		this.gbCalibration = new System.Windows.Forms.GroupBox();
		this.cbTypes = new System.Windows.Forms.ComboBox();
		this.tableLayoutPanel3 = new System.Windows.Forms.TableLayoutPanel();
		this.groupBox8 = new System.Windows.Forms.GroupBox();
		this.dgvCalibrations = new System.Windows.Forms.DataGridView();
		this.colSample = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colConcentration = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colTestValue = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colCPS = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.colInclude = new System.Windows.Forms.DataGridViewCheckBoxColumn();
		this.graph = new ZedGraph.ZedGraphControl();
		this.panel1 = new System.Windows.Forms.Panel();
		this.groupBox7 = new System.Windows.Forms.GroupBox();
		this.txtCoef = new System.Windows.Forms.TextBox();
		this.txtCon = new System.Windows.Forms.TextBox();
		this.txtCPS = new System.Windows.Forms.TextBox();
		this.lblCoef = new System.Windows.Forms.Label();
		this.lblCon = new System.Windows.Forms.Label();
		this.lblCPS = new System.Windows.Forms.Label();
		this.btnRefresh = new System.Windows.Forms.Button();
		this.gbOption = new System.Windows.Forms.GroupBox();
		this.cbForce = new System.Windows.Forms.ComboBox();
		this.cbWeight = new System.Windows.Forms.ComboBox();
		this.lblForce = new System.Windows.Forms.Label();
		this.lblWeight = new System.Windows.Forms.Label();
		this.dataGridViewTextBoxColumn1 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn2 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn3 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		this.dataGridViewTextBoxColumn4 = new System.Windows.Forms.DataGridViewTextBoxColumn();
		((System.ComponentModel.ISupportInitialize)this.splitContainer2).BeginInit();
		this.splitContainer2.Panel1.SuspendLayout();
		this.splitContainer2.Panel2.SuspendLayout();
		this.splitContainer2.SuspendLayout();
		this.gbCalibration.SuspendLayout();
		this.tableLayoutPanel3.SuspendLayout();
		this.groupBox8.SuspendLayout();
		((System.ComponentModel.ISupportInitialize)this.dgvCalibrations).BeginInit();
		this.panel1.SuspendLayout();
		this.groupBox7.SuspendLayout();
		this.gbOption.SuspendLayout();
		base.SuspendLayout();
		this.splitContainer2.Dock = System.Windows.Forms.DockStyle.Fill;
		this.splitContainer2.FixedPanel = System.Windows.Forms.FixedPanel.Panel1;
		this.splitContainer2.Location = new System.Drawing.Point(0, 0);
		this.splitContainer2.Margin = new System.Windows.Forms.Padding(4);
		this.splitContainer2.Name = "splitContainer2";
		this.splitContainer2.Panel1.Controls.Add(this.treeIsotope);
		this.splitContainer2.Panel1.Controls.Add(this.gbCalibration);
		this.splitContainer2.Panel2.Controls.Add(this.tableLayoutPanel3);
		this.splitContainer2.Size = new System.Drawing.Size(1072, 630);
		this.splitContainer2.SplitterDistance = 162;
		this.splitContainer2.SplitterWidth = 5;
		this.splitContainer2.TabIndex = 2;
		this.treeIsotope.Location = new System.Drawing.Point(4, 79);
		this.treeIsotope.Margin = new System.Windows.Forms.Padding(4);
		this.treeIsotope.Name = "treeIsotope";
		this.treeIsotope.Size = new System.Drawing.Size(151, 543);
		this.treeIsotope.TabIndex = 2;
		this.treeIsotope.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(treeIsotope_AfterSelect);
		this.gbCalibration.Controls.Add(this.cbTypes);
		this.gbCalibration.Location = new System.Drawing.Point(4, 4);
		this.gbCalibration.Margin = new System.Windows.Forms.Padding(4);
		this.gbCalibration.Name = "gbCalibration";
		this.gbCalibration.Padding = new System.Windows.Forms.Padding(4);
		this.gbCalibration.Size = new System.Drawing.Size(152, 68);
		this.gbCalibration.TabIndex = 1;
		this.gbCalibration.TabStop = false;
		this.gbCalibration.Text = "类型";
		this.cbTypes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cbTypes.FormattingEnabled = true;
		this.cbTypes.Items.AddRange(new object[4] { "无", "全定量", "标准加入", "半定量" });
		this.cbTypes.Location = new System.Drawing.Point(0, 26);
		this.cbTypes.Margin = new System.Windows.Forms.Padding(4);
		this.cbTypes.Name = "cbTypes";
		this.cbTypes.Size = new System.Drawing.Size(151, 23);
		this.cbTypes.TabIndex = 0;
		this.cbTypes.SelectedIndexChanged += new System.EventHandler(cbTypes_SelectedIndexChanged);
		this.tableLayoutPanel3.ColumnCount = 2;
		this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 67.35294f));
		this.tableLayoutPanel3.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 32.64706f));
		this.tableLayoutPanel3.Controls.Add(this.groupBox8, 0, 1);
		this.tableLayoutPanel3.Controls.Add(this.graph, 0, 0);
		this.tableLayoutPanel3.Controls.Add(this.panel1, 1, 0);
		this.tableLayoutPanel3.Dock = System.Windows.Forms.DockStyle.Fill;
		this.tableLayoutPanel3.Location = new System.Drawing.Point(0, 0);
		this.tableLayoutPanel3.Margin = new System.Windows.Forms.Padding(4);
		this.tableLayoutPanel3.Name = "tableLayoutPanel3";
		this.tableLayoutPanel3.RowCount = 2;
		this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 60f));
		this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 40f));
		this.tableLayoutPanel3.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Absolute, 25f));
		this.tableLayoutPanel3.Size = new System.Drawing.Size(905, 630);
		this.tableLayoutPanel3.TabIndex = 10;
		this.tableLayoutPanel3.SetColumnSpan(this.groupBox8, 2);
		this.groupBox8.Controls.Add(this.dgvCalibrations);
		this.groupBox8.Dock = System.Windows.Forms.DockStyle.Fill;
		this.groupBox8.Location = new System.Drawing.Point(4, 382);
		this.groupBox8.Margin = new System.Windows.Forms.Padding(4);
		this.groupBox8.Name = "groupBox8";
		this.groupBox8.Padding = new System.Windows.Forms.Padding(4);
		this.groupBox8.Size = new System.Drawing.Size(897, 244);
		this.groupBox8.TabIndex = 8;
		this.groupBox8.TabStop = false;
		this.groupBox8.Text = "标准样品数据";
		this.dgvCalibrations.AllowUserToAddRows = false;
		this.dgvCalibrations.AllowUserToDeleteRows = false;
		this.dgvCalibrations.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.AllCells;
		this.dgvCalibrations.BackgroundColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle1.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle1.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle1.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle1.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle1.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle1.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle1.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dgvCalibrations.ColumnHeadersDefaultCellStyle = dataGridViewCellStyle1;
		this.dgvCalibrations.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
		this.dgvCalibrations.Columns.AddRange(this.colSample, this.colConcentration, this.colTestValue, this.colCPS, this.colInclude);
		dataGridViewCellStyle2.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleCenter;
		dataGridViewCellStyle2.BackColor = System.Drawing.SystemColors.Window;
		dataGridViewCellStyle2.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle2.ForeColor = System.Drawing.SystemColors.ControlText;
		dataGridViewCellStyle2.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle2.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle2.WrapMode = System.Windows.Forms.DataGridViewTriState.False;
		this.dgvCalibrations.DefaultCellStyle = dataGridViewCellStyle2;
		this.dgvCalibrations.Dock = System.Windows.Forms.DockStyle.Fill;
		this.dgvCalibrations.Location = new System.Drawing.Point(4, 22);
		this.dgvCalibrations.Margin = new System.Windows.Forms.Padding(4);
		this.dgvCalibrations.Name = "dgvCalibrations";
		dataGridViewCellStyle3.Alignment = System.Windows.Forms.DataGridViewContentAlignment.MiddleLeft;
		dataGridViewCellStyle3.BackColor = System.Drawing.SystemColors.Control;
		dataGridViewCellStyle3.Font = new System.Drawing.Font("宋体", 9f, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, 134);
		dataGridViewCellStyle3.ForeColor = System.Drawing.SystemColors.WindowText;
		dataGridViewCellStyle3.SelectionBackColor = System.Drawing.SystemColors.Highlight;
		dataGridViewCellStyle3.SelectionForeColor = System.Drawing.SystemColors.HighlightText;
		dataGridViewCellStyle3.WrapMode = System.Windows.Forms.DataGridViewTriState.True;
		this.dgvCalibrations.RowHeadersDefaultCellStyle = dataGridViewCellStyle3;
		this.dgvCalibrations.RowHeadersWidth = 51;
		this.dgvCalibrations.RowTemplate.Height = 23;
		this.dgvCalibrations.Size = new System.Drawing.Size(889, 218);
		this.dgvCalibrations.TabIndex = 1;
		this.dgvCalibrations.CellFormatting += new System.Windows.Forms.DataGridViewCellFormattingEventHandler(dgvCalibrations_CellFormatting);
		this.dgvCalibrations.CellValueChanged += new System.Windows.Forms.DataGridViewCellEventHandler(dgvCalibrations_CellValueChanged);
		this.dgvCalibrations.CurrentCellDirtyStateChanged += new System.EventHandler(dgvCalibrations_CurrentCellDirtyStateChanged);
		this.colSample.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colSample.DataPropertyName = "label";
		this.colSample.HeaderText = "样品名";
		this.colSample.MinimumWidth = 6;
		this.colSample.Name = "colSample";
		this.colSample.ReadOnly = true;
		this.colConcentration.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colConcentration.DataPropertyName = "stdCon";
		this.colConcentration.HeaderText = "标准浓度";
		this.colConcentration.MinimumWidth = 6;
		this.colConcentration.Name = "colConcentration";
		this.colConcentration.ReadOnly = true;
		this.colTestValue.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colTestValue.DataPropertyName = "avgCon";
		this.colTestValue.HeaderText = "测量浓度";
		this.colTestValue.MinimumWidth = 6;
		this.colTestValue.Name = "colTestValue";
		this.colTestValue.ReadOnly = true;
		this.colCPS.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colCPS.DataPropertyName = "avgCPS";
		this.colCPS.HeaderText = "CPS";
		this.colCPS.MinimumWidth = 6;
		this.colCPS.Name = "colCPS";
		this.colCPS.ReadOnly = true;
		this.colInclude.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.colInclude.DataPropertyName = "include";
		this.colInclude.HeaderText = "参与计算";
		this.colInclude.MinimumWidth = 6;
		this.colInclude.Name = "colInclude";
		this.colInclude.Resizable = System.Windows.Forms.DataGridViewTriState.True;
		this.colInclude.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.Automatic;
		this.graph.Dock = System.Windows.Forms.DockStyle.Fill;
		this.graph.Location = new System.Drawing.Point(5, 4);
		this.graph.Margin = new System.Windows.Forms.Padding(5, 4, 5, 4);
		this.graph.Name = "graph";
		this.graph.ScrollGrace = 0.0;
		this.graph.ScrollMaxX = 0.0;
		this.graph.ScrollMaxY = 0.0;
		this.graph.ScrollMaxY2 = 0.0;
		this.graph.ScrollMinX = 0.0;
		this.graph.ScrollMinY = 0.0;
		this.graph.ScrollMinY2 = 0.0;
		this.graph.Size = new System.Drawing.Size(599, 370);
		this.graph.TabIndex = 9;
		this.panel1.Controls.Add(this.groupBox7);
		this.panel1.Controls.Add(this.gbOption);
		this.panel1.Dock = System.Windows.Forms.DockStyle.Fill;
		this.panel1.Location = new System.Drawing.Point(613, 4);
		this.panel1.Margin = new System.Windows.Forms.Padding(4);
		this.panel1.Name = "panel1";
		this.panel1.Size = new System.Drawing.Size(288, 370);
		this.panel1.TabIndex = 10;
		this.groupBox7.Controls.Add(this.txtCoef);
		this.groupBox7.Controls.Add(this.txtCon);
		this.groupBox7.Controls.Add(this.txtCPS);
		this.groupBox7.Controls.Add(this.lblCoef);
		this.groupBox7.Controls.Add(this.lblCon);
		this.groupBox7.Controls.Add(this.lblCPS);
		this.groupBox7.Controls.Add(this.btnRefresh);
		this.groupBox7.Dock = System.Windows.Forms.DockStyle.Fill;
		this.groupBox7.Location = new System.Drawing.Point(0, 95);
		this.groupBox7.Margin = new System.Windows.Forms.Padding(4);
		this.groupBox7.Name = "groupBox7";
		this.groupBox7.Padding = new System.Windows.Forms.Padding(4);
		this.groupBox7.Size = new System.Drawing.Size(288, 275);
		this.groupBox7.TabIndex = 7;
		this.groupBox7.TabStop = false;
		this.groupBox7.Text = "曲线参数";
		this.txtCoef.Location = new System.Drawing.Point(147, 135);
		this.txtCoef.Margin = new System.Windows.Forms.Padding(4);
		this.txtCoef.Name = "txtCoef";
		this.txtCoef.ReadOnly = true;
		this.txtCoef.Size = new System.Drawing.Size(132, 25);
		this.txtCoef.TabIndex = 35;
		this.txtCon.Location = new System.Drawing.Point(147, 96);
		this.txtCon.Margin = new System.Windows.Forms.Padding(4);
		this.txtCon.Name = "txtCon";
		this.txtCon.ReadOnly = true;
		this.txtCon.Size = new System.Drawing.Size(132, 25);
		this.txtCon.TabIndex = 34;
		this.txtCPS.Location = new System.Drawing.Point(147, 56);
		this.txtCPS.Margin = new System.Windows.Forms.Padding(4);
		this.txtCPS.Name = "txtCPS";
		this.txtCPS.ReadOnly = true;
		this.txtCPS.Size = new System.Drawing.Size(132, 25);
		this.txtCPS.TabIndex = 33;
		this.lblCoef.AutoSize = true;
		this.lblCoef.Location = new System.Drawing.Point(8, 138);
		this.lblCoef.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.lblCoef.Name = "lblCoef";
		this.lblCoef.Size = new System.Drawing.Size(75, 15);
		this.lblCoef.TabIndex = 32;
		this.lblCoef.Text = "相关系数:";
		this.lblCon.AutoSize = true;
		this.lblCon.Location = new System.Drawing.Point(8, 99);
		this.lblCon.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.lblCon.Name = "lblCon";
		this.lblCon.Size = new System.Drawing.Size(75, 15);
		this.lblCon.TabIndex = 31;
		this.lblCon.Text = "浓度截距:";
		this.lblCPS.AutoSize = true;
		this.lblCPS.Location = new System.Drawing.Point(8, 59);
		this.lblCPS.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.lblCPS.Name = "lblCPS";
		this.lblCPS.Size = new System.Drawing.Size(75, 15);
		this.lblCPS.TabIndex = 30;
		this.lblCPS.Text = "强度截距:";
		this.btnRefresh.Location = new System.Drawing.Point(80, 201);
		this.btnRefresh.Margin = new System.Windows.Forms.Padding(4);
		this.btnRefresh.Name = "btnRefresh";
		this.btnRefresh.Size = new System.Drawing.Size(145, 29);
		this.btnRefresh.TabIndex = 13;
		this.btnRefresh.Text = "重新计算";
		this.btnRefresh.UseVisualStyleBackColor = true;
		this.btnRefresh.Click += new System.EventHandler(btnRefreshResult_Click);
		this.gbOption.Controls.Add(this.cbForce);
		this.gbOption.Controls.Add(this.cbWeight);
		this.gbOption.Controls.Add(this.lblForce);
		this.gbOption.Controls.Add(this.lblWeight);
		this.gbOption.Dock = System.Windows.Forms.DockStyle.Top;
		this.gbOption.Location = new System.Drawing.Point(0, 0);
		this.gbOption.Margin = new System.Windows.Forms.Padding(4);
		this.gbOption.Name = "gbOption";
		this.gbOption.Padding = new System.Windows.Forms.Padding(4);
		this.gbOption.Size = new System.Drawing.Size(288, 95);
		this.gbOption.TabIndex = 2;
		this.gbOption.TabStop = false;
		this.gbOption.Text = "选项";
		this.cbForce.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cbForce.FormattingEnabled = true;
		this.cbForce.Items.AddRange(new object[3] { "无", "空白", "原点" });
		this.cbForce.Location = new System.Drawing.Point(147, 56);
		this.cbForce.Margin = new System.Windows.Forms.Padding(4);
		this.cbForce.Name = "cbForce";
		this.cbForce.Size = new System.Drawing.Size(132, 23);
		this.cbForce.TabIndex = 3;
		this.cbForce.SelectedIndexChanged += new System.EventHandler(cbForce_SelectedIndexChanged);
		this.cbWeight.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
		this.cbWeight.FormattingEnabled = true;
		this.cbWeight.Items.AddRange(new object[3] { "无", "绝对偏差", "相对偏差" });
		this.cbWeight.Location = new System.Drawing.Point(147, 19);
		this.cbWeight.Margin = new System.Windows.Forms.Padding(4);
		this.cbWeight.Name = "cbWeight";
		this.cbWeight.Size = new System.Drawing.Size(132, 23);
		this.cbWeight.TabIndex = 2;
		this.lblForce.AutoSize = true;
		this.lblForce.Location = new System.Drawing.Point(20, 59);
		this.lblForce.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.lblForce.Name = "lblForce";
		this.lblForce.Size = new System.Drawing.Size(75, 15);
		this.lblForce.TabIndex = 1;
		this.lblForce.Text = "强制通过:";
		this.lblWeight.AutoSize = true;
		this.lblWeight.Location = new System.Drawing.Point(20, 22);
		this.lblWeight.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
		this.lblWeight.Name = "lblWeight";
		this.lblWeight.Size = new System.Drawing.Size(75, 15);
		this.lblWeight.TabIndex = 0;
		this.lblWeight.Text = "加权方式:";
		this.dataGridViewTextBoxColumn1.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn1.DataPropertyName = "label";
		this.dataGridViewTextBoxColumn1.HeaderText = "样品名";
		this.dataGridViewTextBoxColumn1.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn1.Name = "dataGridViewTextBoxColumn1";
		this.dataGridViewTextBoxColumn1.ReadOnly = true;
		this.dataGridViewTextBoxColumn2.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn2.DataPropertyName = "stdCon";
		this.dataGridViewTextBoxColumn2.HeaderText = "标准浓度";
		this.dataGridViewTextBoxColumn2.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn2.Name = "dataGridViewTextBoxColumn2";
		this.dataGridViewTextBoxColumn2.ReadOnly = true;
		this.dataGridViewTextBoxColumn3.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn3.DataPropertyName = "avgCon";
		this.dataGridViewTextBoxColumn3.HeaderText = "测量浓度";
		this.dataGridViewTextBoxColumn3.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn3.Name = "dataGridViewTextBoxColumn3";
		this.dataGridViewTextBoxColumn3.ReadOnly = true;
		this.dataGridViewTextBoxColumn4.AutoSizeMode = System.Windows.Forms.DataGridViewAutoSizeColumnMode.Fill;
		this.dataGridViewTextBoxColumn4.DataPropertyName = "avgCPS";
		this.dataGridViewTextBoxColumn4.HeaderText = "CPS";
		this.dataGridViewTextBoxColumn4.MinimumWidth = 6;
		this.dataGridViewTextBoxColumn4.Name = "dataGridViewTextBoxColumn4";
		this.dataGridViewTextBoxColumn4.ReadOnly = true;
		base.AutoScaleDimensions = new System.Drawing.SizeF(8f, 15f);
		base.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
		base.ClientSize = new System.Drawing.Size(1072, 630);
		base.Controls.Add(this.splitContainer2);
		base.Margin = new System.Windows.Forms.Padding(4);
		base.Name = "FormCurves";
		base.ShowIcon = false;
		this.Text = "FormCurves";
		base.Activated += new System.EventHandler(FormCurves_Activated);
		base.Load += new System.EventHandler(FormCurves_Load);
		this.splitContainer2.Panel1.ResumeLayout(false);
		this.splitContainer2.Panel2.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.splitContainer2).EndInit();
		this.splitContainer2.ResumeLayout(false);
		this.gbCalibration.ResumeLayout(false);
		this.tableLayoutPanel3.ResumeLayout(false);
		this.groupBox8.ResumeLayout(false);
		((System.ComponentModel.ISupportInitialize)this.dgvCalibrations).EndInit();
		this.panel1.ResumeLayout(false);
		this.groupBox7.ResumeLayout(false);
		this.groupBox7.PerformLayout();
		this.gbOption.ResumeLayout(false);
		this.gbOption.PerformLayout();
		base.ResumeLayout(false);
	}
}
